import {createRouter, createWebHistory} from 'vue-router'
import routes from './router'
import {
    createDiscreteApi
  } from "naive-ui";

const router = createRouter({
    history: createWebHistory(), 
    routes
})

// 路由守卫
router.beforeEach((to,from,next) =>{
    const token = localStorage.getItem("token");
    const message = createDiscreteApi(["message"]).message;
    // 登录页面
    if(to.path=='/login'){
        next()
    }else{
        // 非登录页面
        if(token!=null){
            // /views/Cate.vue
            next()
        }
    }
})
 
export default router